﻿///输入字符小游戏f
namespace RandomNumGame
{
    internal class Program
    {
        static void Main(string[] args)
        {

            DateTime BeforeRuning = DateTime.Now; 
            char MyLetter;
            char RandomLetter;
            int Right = 0;
            int Wrong = 0;
            ///随机数对象
            Random RndNum=new Random();
            ///由玩家设定玩的局数
            Console.WriteLine("Input a number that decide your game rounds:");
            int round=int.Parse(Console.ReadLine());
            ///判断循环
            for (int i = 1; i <= round; i++)
            {
                Console.Clear();
                RandomLetter = GetLetter(RndNum);
                Console.WriteLine(RandomLetter);
                Console.WriteLine("Input your answer,please；");
                MyLetter = char.Parse(Console.ReadLine());
                bool decide = MyLetter == RandomLetter;
                if (decide)
                {
                    Right++;
                }
                else
                {
                    Wrong++;
                }
            }
            ///正确与错误局数
            Console.Write("RightRound:");
            Console.WriteLine(Right);
            Console.Write("WrongRound:");
            Console.WriteLine(Wrong);
            ///计算代码运行时间
            DateTime AfterRuning = DateTime.Now;
            TimeSpan RuningTime = AfterRuning.Subtract(BeforeRuning);
            Console.Write("Runing time:");
            Console.WriteLine(RuningTime);
        }

        
        /// 生成随机数函数
       
        static char GetLetter(Random letter)
        {
            int i = letter.Next(65, 123);
            char j = (char)i;
            if (char.IsLetter(j))
            {
                return j;
            }
            else 
            {
                ///递归调用保证返回的是字母
                return GetLetter(letter);
            }
        }
    }
}
       

      
            
                